public class Learn3 {
    public static void main(String[] args) {
        for (int i = 0; i < 100000; i++) {     //十万以内的水仙花数
            int count = 0;
            int num = i;
            while (num != 0){
                num /=10;
                count++;
            }
            num = i;
            int sum = 0;
            while(num != 0){
                sum += Math.pow(num % 10,count);
                num /= 10;
            }
            if (sum == i){
                System.out.println(i);
            }
        }
    }
    public static void main1(String[] args) {
        int i = 100;
        for ( ; i < 1000 ; i++) {
            int num = i;
            int ret = 0;
            while(num != 0){
                ret += (num % 10)*(num % 10)*(num % 10); //只适合3位数
                num = num / 10;
            }
            if(ret == i){
                System.out.println(i);
            }
        }
    }
}
